import 'package:flutter/material.dart';
import 'package:flutter_massage/common_lib/extension/ex_widget.dart';
import 'package:flutter_massage/common_lib/index.dart';
import 'package:flutter_massage/common_lib/routers/route.dart';
import 'package:flutter_massage/common_lib/ui/common_component.dart';
import 'package:flutter_massage/pages/my/order/order_detail/order_detail_page.dart';
import 'package:flutter_massage/pages/my/wallet/my_wallte_logic.dart';
import 'package:flutter_massage/pages/technician/place_order/order_bean.dart';
import 'package:flutter_massage/pages/web/web_view.dart';
import 'package:flutter_massage/values/index.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

class MyWalletPage extends GetView<MyWalletLogic> {
  const MyWalletPage({super.key});

  @override
  Widget build(BuildContext context) {
    return BaseScaffold(
      scaffoldBackgroundColor: AppColors.grayF8,
      child: GetBuilder<MyWalletLogic>(
        init: MyWalletLogic(),
        assignId: true,
        builder: (logic) {
          return logic.url.notEmpty ? WebH5Page(url: logic.url, title: '我的钱包', showBack: false) : Container();
        },
      ),
    );
  }
}

class MyOrderItem extends StatelessWidget {
  const MyOrderItem(this.bean, {super.key});

  final OrderBean bean;

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: CommonDecoration.getRadius(all: 8.w, bg: AppColors.white),
      child: CommonListItemScaffold(
        contentPadding: EdgeInsets.all(16.w),
        left: ImageWidget.url(bean.projectBean?.itemImage ?? '', width: 80.w, height: 80.w, radius: 6.w),
        center: CommonMargin.width(8.w),
        right: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            TextWidget.moreLine(
              text: bean.projectBean?.itemName ?? '',
              fontSize: 15,
              color: AppColors.textLevelOne,
              fontWeight: FontWeight.bold,
            ),
            Row(
              children: [
                TextWidget.oneLine(
                  text: '¥${bean.projectBean?.itemPrice.removeYuan()}',
                  fontSize: 12,
                  color: AppColors.primaryOrange,
                  fontWeight: FontWeight.bold,
                ).expanded(),
                const TextWidget.oneLine(
                  text: 'x 1',
                  fontSize: 11,
                  color: AppColors.textLevelOne,
                ),
              ],
            ).paddingTop(10.w),
            TextWidget.oneLine(
              text: bean.projectBean?.itemLabel ?? '',
              fontSize: 12,
              color: AppColors.textLevelTwo,
              fontWeight: FontWeight.bold,
            ).paddingTop(10.w),
          ],
        ).expanded(),
        bottom: Row(
          children: [
            TextWidget.oneLine(
              text: '服务时间：${bean.time}',
              fontSize: 12,
              color: AppColors.textLevelThree,
            ).expanded(),
            Text.rich(
              TextSpan(
                text: '¥',
                children: [
                  TextSpan(
                    text: bean.projectBean?.itemPrice.removeYuan(),
                    style: const TextStyle(
                      fontSize: 17,
                      color: AppColors.primaryOrange,
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                ],
                style: const TextStyle(
                  fontSize: 12,
                  color: AppColors.primaryOrange,
                  fontWeight: FontWeight.bold,
                ),
              ),
            )
          ],
        ).paddingTop(10.w),
        onTap: () => CommonRoute.open(OrderDetailPage(bean)),
      ),
    );
  }
}
